import { Field, Int, ObjectType } from '@nestjs/graphql';
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import * as mongoose from 'mongoose';

@Schema({ timestamps: true })
@ObjectType('User')
export class UserEntity {
  @Field()
  _id: string;

  @Prop({ index: true })
  @Field()
  userName: string;

  @Prop()
  password: string;

  @Prop()
  @Field()
  name: string;

  @Prop({ default: 0 })
  @Field(() => Int)
  EXP: number;
}
export type UserDocument = UserEntity & mongoose.Document;
export const UserSchema = SchemaFactory.createForClass(UserEntity);
